using Bulb.Core.Services;
using Cirrious.CrossCore;
using Cirrious.CrossCore.IoC;
using Cirrious.MvvmCross.Plugins.JsonLocalisation;


namespace Bulb.Core
{
    public class App : Cirrious.MvvmCross.ViewModels.MvxApplication
    {
        public override void Initialize()
        {
            Register("Repository", "Service");
				
            RegisterAppStart<ViewModels.HomeViewModel>();

            InitializeText();
        }

        private void Register(params string[] names)
        {
            foreach (var name in names)
                CreatableTypes()
                    .EndingWith(name)
                    .AsInterfaces()
                    .RegisterAsLazySingleton();
        }

        private void InitializeText()
        {
            var builder = new TextProviderBuilder();
            Mvx.RegisterSingleton<IMvxTextProviderBuilder>(builder);
            Mvx.RegisterSingleton(builder.TextProvider);
        }
    }
}